<include file="Index:header"/>
<include file="Index:menu"/>

	<div class="row">
	  <div class="col-md-5">
		  <div class="form-group">
			<label for="login_email">Email</label>
			<input type="email" class="form-control" name="login_email" id="login_email" placeholder="username@example.com">
		  </div>
		  <div class="form-group">
			<label for="login_password">Password</label>
			<input type="password" class="form-control" id="login_password" name="login_password" placeholder="Password">
		  </div>
		  <button id="do_login" class="btn btn-success">登录</button>
	  </div>
	  <div class="col-md-5 col-md-offset-2">
		  <div class="form-group">
			<label for="reg_nickname">NickName</label>
			<input type="text" class="form-control" name="reg_nickname" id="reg_nickname" placeholder="nickname">
		  </div>
		  <div class="form-group">
			<label for="reg_email">Email</label>
			<input type="email" class="form-control" name="reg_email" id="reg_email" placeholder="username@example.com">
		  </div>
		  <div class="form-group">
			<label for="reg_password">Password</label>
			<input type="password" class="form-control" id="reg_password" name="reg_password" placeholder="Password">
		  </div>
		  <div class="form-group">
			<label for="reg_rpassword">ReType Password</label>
			<input type="password" class="form-control" id="reg_rpassword" name="reg_rpassword" placeholder="ReType Password">
		  </div>
		  <button id="do_reg" class="btn btn-info">注册</button>
	  </div>
	</div>
<script>
	$("#do_login").click(function(){
		var login_email = $("#login_email").val();
		var login_password = $("#login_password").val();
		$.post("{:U('User/do_login')}",{email:login_email,password:login_password},function(result){
			if(result.ok==1){
				var msg = new $.zui.Messager('登录成功！', {placement: 'center',type:'success'});
				location.href=result.url;
			}else{
				var msg = new $.zui.Messager('用户名密码错误！', {placement: 'center',type:'danger'});
			}
			msg.show();
		});
	});
	
	$("#do_reg").click(function(){
		var reg_nickname = $("#reg_nickname").val();
		var reg_email = $("#reg_email").val();
		var reg_password = $("#reg_password").val();
		var reg_rpassword = $("#reg_rpassword").val();
		if(!reg_nickname){
			var msg = new $.zui.Messager('请填写昵称！', {placement: 'center',type:'danger'});
			msg.show();
			return ;
		}
		if(!reg_email){
			var msg = new $.zui.Messager('请填写邮箱！', {placement: 'center',type:'danger'});
			msg.show();
			return ;
		}		
		if(!reg_password){
			var msg = new $.zui.Messager('请输入密码！', {placement: 'center',type:'danger'});
			msg.show();
			return ;
		}
		if(reg_password!=reg_rpassword){
			var msg = new $.zui.Messager('两次密码不一致', {placement: 'center',type:'danger'});
			msg.show();
			return ;
		}
		$.post("{:U('User/do_reg')}",{nickname:reg_nickname,email:reg_email,password:reg_password,rpassword:reg_rpassword},function(result){
			if(result.ok==1){
				var msg = new $.zui.Messager('注册登录成功！', {placement: 'center',type:'success'});
			}else{
				var msg = new $.zui.Messager('已有该邮箱了', {placement: 'center',type:'danger'});
			}
			msg.show();
		});
	});
</script>
<include file="Index:footer"/>